package com.pd.backend.controller;

import com.pd.backend.dtos.PdTruckTypeDto;
import com.pd.backend.dtos.ResponseResult;
import com.pd.backend.dtos.TruckTypeDto;
import com.pd.backend.service.TruckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 转运中心车辆类型业务层
 *
 * @author wjj
 * @date 2023/1/11 10:56
 **/
@RestController
@RequestMapping("/transfor-center")
public class TruckController {

    @Autowired
    private TruckService truckService;

    /**
     * 分页查询车型管理
     * @param truckTypeDto
     * @return
     */
    @GetMapping("/bussiness/truckType")
    public ResponseResult findPage(@RequestBody TruckTypeDto truckTypeDto) {
        return truckService.selectAllTruckType(truckTypeDto);
    }

    /**
     * 新增车队管理
     * @param pdTruckTypeDto
     * @return
     */
    @PostMapping("/bussiness/truckType")
    public ResponseResult insertTruckType(@RequestBody PdTruckTypeDto pdTruckTypeDto) {
        return truckService.insertTruckType(pdTruckTypeDto);
    }

    /**
     * 修改车型管理
     * @param pdTruckTypeDto
     * @return
     */
    @PutMapping("/bussiness/truckType")
    public ResponseResult updateTruckType(@RequestBody PdTruckTypeDto pdTruckTypeDto) {
        return truckService.updateTruckType(pdTruckTypeDto);
    }

    /**
     * 删除车型
     * @param id
     * @return
     */
    @DeleteMapping("/bussiness/truckType/{id}")
    public ResponseResult deleteTruckType(@PathVariable("id") String id) {
        return truckService.deleteTruckType(id);
    }

}
